package com.example.englishwars2d;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;

import javax.microedition.khronos.opengles.GL10;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.net.Uri;
import android.util.FloatMath;
import android.util.Log;

import com.badlogic.androidgames.framework.Game;
import com.badlogic.androidgames.framework.Input.TouchEvent;
import com.badlogic.androidgames.framework.Screen;
import com.badlogic.androidgames.framework.gl.Animation;
import com.badlogic.androidgames.framework.gl.Font;
import com.badlogic.androidgames.framework.gl.SpriteBatcher;
import com.badlogic.androidgames.framework.gl.Texture;
import com.badlogic.androidgames.framework.gl.TextureRegion;
import com.badlogic.androidgames.framework.gl.Vertices;
import com.badlogic.androidgames.framework.impl.GLGraphics;
import com.badlogic.androidgames.framework.math.OverlapTester;
import com.badlogic.androidgames.framework.math.Vector2;


public class CollisionTest extends GLGame {

    enum EnemyType {
    	None,
        Ship,
        Giant,
        Submarine
    }
    boolean isPlaying= false;
    @Override
    public Screen getStartScreen() {
    	mPlayer = new MediaPlayer();
    	mPlayer.setOnCompletionListener(mOnComplete);
        return new CollisionScreen(this);
    }
    
    MediaPlayer.OnCompletionListener mOnComplete = 
    		new MediaPlayer.OnCompletionListener() {
		public void onCompletion(MediaPlayer arg0) {
			isPlaying = false;
		}
    };    

    
	static class Enemy extends DynamicGameObject {
	    public float walkingTime = 0;
	    boolean isVisible;
	    public int hitCount= 0;
		public EnemyType enemyName;
	    public Enemy(EnemyType type, float x, float y, float width, float height) {
	        super(x, y, width, height);
	        this.position.set(x, y);
	        this.velocity.set(-0.2f, 0);
	        this.walkingTime = (float)Math.random() * 10;
	        isVisible = true;
	        enemyName = type;
	    }        
	    
	    public void update(float deltaTime) {        
	        position.add(velocity.x * deltaTime, velocity.y * deltaTime);
	        if(position.x < 0) {
	        	isVisible = false;
//	        	position.x = WORLD_WIDTH;
	        }
	        if(position.x > WORLD_WIDTH) position.x = 0;
	        bounds.lowerLeft.x = position.x;
	        walkingTime += deltaTime;
	    }
	}
	

class CollisionScreen extends Screen {
//    final int NUM_TARGETS = 20;
	int mScoreNum= 0;
    final int NUM_TARGETS = 1;
    final int NUM_BLOCKS = 7;
    static final int NUM_CAVEMEN = 1;
    static final int ALPHA_NUM = 26;
    Font mFont;
    GLGraphics glGraphics;        
    Cannon cannon;
    DynamicGameObject ball;
   boolean isHit;
    SpriteBatcher batcher;
//    Bitmap mBitmap;
    List<GameObject> alphabets;
    List<GameObject> castle;
    Vertices cannonVertices;
    Vertices ballVertices;
    Vertices targetVertices;
    Vertices castleVertices;
    Vertices oceanVertices;
    Vertices backVertices;
    Vertices wordVertices;
    String mOuputText;
    GameObject sea;
    Vector2 touchPos = new Vector2();
    Vector2 gravity = new Vector2(0,-10);
    Texture texture, texture2, texture3, background, explosionTexture, wordTex;
    SoundPool mSoundPool;
    boolean isFired =false;
    Animation walkAnim, explosionAnim;
    boolean isStart =true;
//    Bubble bubble;
    TextureRegion[] wordRegions;
    int mSoundId;
    
    public CollisionScreen(Game game) {
        super(game);
        glGraphics = ((GLGame)game).getGLGraphics();
        batcher = new SpriteBatcher(glGraphics, 100);	    
        wordRegions = new TextureRegion[ALPHA_NUM];
        cannon = new Cannon(0.5f, 3, 1, 1);
        ball = new DynamicGameObject(0, 0, 0.2f, 0.2f);
        
        alphabets = new ArrayList<GameObject>(ALPHA_NUM); 
        
        targets = new ArrayList<Enemy>(NUM_TARGETS);
        castle = new ArrayList<GameObject>(NUM_BLOCKS);
        sea = new GameObject(0.7f, 0.0f, WORLD_WIDTH - 0.7f, 0.5f); 

//        grid = new SpatialHashGrid(WORLD_WIDTH, WORLD_HEIGHT, 2.5f);
        mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
        mSoundId = mSoundPool.load(MyApplication.getContext(), R.raw.click, 0);
        for(int i = 0; i < NUM_BLOCKS; i++) {
        	GameObject block = new GameObject(0.0f+i*0.1f, 
        			0.0f-0.2f*(i%2),
        			0.1f, 3.0f);  
//        	grid.insertStaticObject(block);
        	castle.add(block);
        }                        
        
        cannonVertices = new Vertices(glGraphics, 4, 6, false, true);
        cannonVertices.setVertices(new float[] { -0.5f, -0.25f, 0.0f, 0.5f, 
                                                  0.5f, -0.25f, 1.0f, 0.5f,
                                                  0.5f,  0.25f, 1.0f, 0.0f,
                                                 -0.5f,  0.25f, 0.0f, 0.0f }, 
                                                 0, 16);
        cannonVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6);
        
        ballVertices = new Vertices(glGraphics, 4, 6, false, true);            
        ballVertices.setVertices(new float[] { -0.1f, -0.1f, 0.0f, 0.75f,
                                                0.1f, -0.1f, 0.25f, 0.75f,
                                                0.1f,  0.1f, 0.25f, 0.5f,
                                               -0.1f,  0.1f, 0.0f, 0.5f }, 
                                                0, 16);
        ballVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6);
        
        targetVertices = new Vertices(glGraphics, 4, 6, false, true);
        targetVertices.setVertices(new float[] { -0.5f, -0.25f, 0.0f, 1.0f,
                                                  0.5f, -0.25f, 1.0f, 1.0f,
                                                  0.5f,  0.25f, 1.0f, 0.0f,
                                                 -0.5f,  0.25f, 0.0f, 0.0f }, 
                                                 0, 16);
        targetVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6);
        
        castleVertices = new Vertices(glGraphics, 4, 6, true, false);
        castleVertices.setVertices(new float[] { 0.0f, 0.0f, 1, 0, 0, 1, 
        		0.1f, 0.0f, 1, 0, 0, 1, 
        		0.1f,  3.0f, 1, 0, 0, 1, 
        		0.0f,  3.0f, 1, 0, 0, 1}, 0, 24/*8*/);
        castleVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6); 

        oceanVertices = new Vertices(glGraphics, 4, 6, true, false);
        oceanVertices.setVertices(new float[] { 0.0f, 0.0f, 0, 0, 1, 0.5f, 
        		 WORLD_WIDTH - 0.7f, 0.0f, 0, 0, 1, 0.5f, 
        		 WORLD_WIDTH - 0.7f,  0.5f, 0, 0, 1, 0.5f, 
        		0.0f,  0.5f, 0, 0, 1, 0.5f }, 0, 24/*8*/);
        oceanVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6); 
        backVertices = new Vertices(glGraphics, 4, 6, false, true);
        backVertices.setVertices(new float[] { 1.0f, 1.0f, 0, 1,  
        		WORLD_WIDTH-1, 1.0f, 1, 1, 
        		WORLD_WIDTH-1,  WORLD_HEIGHT-1, 1, 0, 
        		1.0f,  WORLD_HEIGHT-1, 0, 0}, 0, 16); 
        backVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6); 
        
//        wordVertices = new Vertices(glGraphics, 4, 6, false, true);
//        wordVertices.setVertices(new float[] { -0.5f, -0.5f, 0.0f, 1.0f,
//                0.5f, -0.5f, 1.0f, 1.0f,
//                0.5f,  0.5f, 1.0f, 0.0f,
//               -0.5f,  0.5f, 0.0f, 0.0f }, 
//               0, 16);
//        wordVertices.setIndices(new short[] {0, 1, 2, 2, 3, 0}, 0, 6);
    }


	private void playSound() {
		if (isPlaying)
			return;
		isPlaying = true;
		new Thread(){
			
			@Override
			public void run() {
		        mPlayer.reset();

				String loc = 
				"http://translate.google.com/translate_tts?" +
				"tl=en&q="+ mQuestion;
				Log.i("Test", loc);
				Uri uri = Uri.parse(loc);
				if (LoadMedia(uri)){
					try {
						mPlayer.start();
					} catch (Exception e) {
						// Toast.makeText(MyApplication.getContext(), "error : " +
						// e.getMessage(), 0).show();
					}		
				}
			}
			
		}.start();

	}

    // 항상 준비 상태여야 한다.
    boolean LoadMedia(Uri uri) {
		try {
			mPlayer.setDataSource(CollisionTest.this, uri);
			mPlayer.prepare();
		} catch (IllegalArgumentException e) {
			return false;
		} catch (IllegalStateException e) {
			return false;
		} catch (IOException e) {
			return false;
		}

		return true;
    }
    
    public void makeEnemy() {
    	isCorrectAnswer = false;
    	float rand = (float)Math.random();
    	Log.i("Test", "rand: "+rand);
    	if (rand>0.5f){
    		eType = EnemyType.Giant;
            for(int i = 0; i < NUM_CAVEMEN; i++) {
            	Enemy giant  = new Enemy(eType, WORLD_WIDTH, 1.5f, 1, 3.0f);
            	targets.add(giant);
            }
            		
    	} else {
    		eType = EnemyType.Ship;
	        for(int i = 0; i < NUM_TARGETS; i++) {
	        	Enemy target = new Enemy(eType, WORLD_WIDTH, 0.75f, 0.5f, 0.5f);  
	            targets.add(target);
	        }        
    	}
    	
		if (mCursor.moveToNext()){
			mQuestion = mCursor.getString(1);
			mMeaning = mCursor.getString(2);
			mPictureFile = mCursor.getString(3);
	        background = new Texture(((GLGame)game), mPictureFile);
			Log.i("Test", "question:"+mQuestion);
		}
		playSound();
		mOuputText = makeSortedtring(mQuestion)+"_<";
        for(int i = 0; i < mOuputText.length(); i++) {
            GameObject word = new GameObject(0.4f+i*0.4f, WORLD_HEIGHT-0.8f, 0.4f, 0.4f);  
            alphabets.add(word);
        } 
	}
    
    public String makeSortedtring(String str){
    	str= str.replace(" ", "");
    	str= str.toLowerCase();
    	Log.i("Test", str);
    	int len = str.length();
    	ArrayList<String> sortedStrList = new ArrayList<String>();
    	for (int i = 0; i<len; i++){
    		sortedStrList.add(String.valueOf(str.charAt(i)));
    	}
 	
    	ArrayList<String> sort_result = new ArrayList<String>(
    			new HashSet<String>(sortedStrList));

    	Collections.sort(sort_result);   
    	String sortedStr = "";     
    	for (int i = 0; i<sort_result.size(); i++){
    		sortedStr += sort_result.get(i);
    	}
    	Log.i("Test", sortedStr);
    	return sortedStr;
    }

    
	@Override
	public void update(float deltaTime) {
		GL10 gl = glGraphics.getGL();
//		if (isStart){
//			isStart = false;
//			makeEnemy();
//		}

        if (addedTime>1){
        	addedTime = 0;
        	if (isUpdated){
        		makeEnemy();
        		isUpdated = false;
        	}
        }
	    for(int j = 0; j < targets.size(); j++) {
        	Enemy target = targets.get(j);
        	target.update(deltaTime);	
        	if (!target.isVisible) {
        		eType = EnemyType.None;
	            targets.remove(target);
	            isUpdated = true;
	            isCorrectAnswer = false;
        	}
	    }

	    List<TouchEvent> touchEvents = game.getInput().getTouchEvents();
	    game.getInput().getKeyEvents();
	    
	    int len = touchEvents.size();
	    for (int i = 0; i < len; i++) {
	        TouchEvent event = touchEvents.get(i);

	        float clickX = touchPos.x = (event.x / (float) glGraphics.getWidth())* WORLD_WIDTH;
	        float clixkY = touchPos.y = (1 - event.y / (float) glGraphics.getHeight()) * WORLD_HEIGHT;
	    	Log.i("Test", "Touched!! x:"+touchPos.x+", y:"+touchPos.y+"size: "+targets.size());
//	    	float clickX = 0;
//	    	float clixkY = 0;
//	    	if (event.type == TouchEvent.TOUCH_DOWN){
//	    		clickX = touchPos.x;
//	    		clixkY = touchPos.y;
//	    	}
	        if (isCorrectAnswer){
	        	cannon.angle = touchPos.sub(cannon.position).angle();                       
	        }
	        if(event.type == TouchEvent.TOUCH_UP && isCorrectAnswer) {
	        	isFired = true;
	            float radians = cannon.angle * Vector2.TO_RADIANS;
	            float ballSpeed = touchPos.len() * 2;
	            ball.position.set(cannon.position);
	            ball.velocity.x = FloatMath.cos(radians) * ballSpeed;
	            ball.velocity.y = FloatMath.sin(radians) * ballSpeed;
	            ball.bounds.lowerLeft.set(ball.position.x - 0.1f, ball.position.y - 0.1f);
	        }
	        if (event.type == TouchEvent.TOUCH_DOWN){
		        for(int j = 0; j < targets.size(); j++) {
		        	Enemy target = targets.get(j);
	//	        	Log.i("Test", "target x: "+target.bounds.lowerLeft.x+", y:"+target.bounds.lowerLeft.y+
	//	        			", w:"+target.bounds.width+", h:"+target.bounds.height);
		            if (OverlapTester.pointInRectangle(target.bounds, clickX, clixkY)){
		            	Log.i("Test", "clicked!!");
						playSound();
		            }
	
		        }
		        
		        for (int j= 0; j<mOuputText.length(); j++){
		        	GameObject word = alphabets.get(j);
		        	String temp = String.valueOf(mOuputText.charAt(j));
		        	if (mAnswerView.getText().length() == 0){
		        		temp = temp.toUpperCase();
		        	}
		        	final String str= temp;
		        	if (OverlapTester.pointInRectangle(word.bounds, clickX, clixkY)){
		        		mSoundPool.play(mSoundId, 1.0f, 1.0f, 1, 0, 1.0f);
		        		Log.i("Test", temp);
			            mAnswerView.post(new Runnable() {
			    			@Override
			    			public void run() {
			    				String curStr = mAnswerView.getText().toString();
			    				if (str.equalsIgnoreCase("<")){
			    					if (curStr.length()>0){
				    					mAnswerView.setText(curStr.substring(0, 
				    							curStr.length()-1));
			    					}
			    				} else if (str.equalsIgnoreCase("_")){
			    					mAnswerView.setText(curStr+" ");
			    				} else {
			    					mAnswerView.setText(curStr+str);
			    				}
			    			}
			    		});
		        		
		            }
		        }
		        
		        
	        }

	    }
	    if (isCorrectAnswer){                     
		    ball.velocity.add(gravity.x * deltaTime, gravity.y * deltaTime);
		    ball.position.add(ball.velocity.x * deltaTime, ball.velocity.y * deltaTime);
		    ball.bounds.lowerLeft.add(ball.velocity.x * deltaTime, ball.velocity.y * deltaTime);
	
	
//		    List<GameObject> colliders = grid.getPotentialColliders(ball);
//		    len = colliders.size(); 

		    len = targets.size(); 
	
		    //볼이 타켓에 맞았는지 체크 
		    for(int i = 0; i < len; i++) {
		        Enemy target = targets.get(i);
//		        Log.i("Test", "target x:"+target.bounds.lowerLeft.x+", " +
//		        		"y:"+target.bounds.lowerLeft.y);
		        if(OverlapTester.overlapRectangles(ball.bounds, target.bounds)) {
		        	isFired = false;
//						gl.glDisable(GL10.GL_LIGHTING);
		        	renderExplosion(gl, ball.position, target.walkingTime);
//			        	gl.glEnable(GL10.GL_LIGHTING);
		        	ball.bounds.lowerLeft.x = ball.bounds.lowerLeft.y = 0;
		        	ball.position.x = ball.position.y = 0;
		        	
		        	target.hitCount++;
		        	if (target.enemyName == EnemyType.Giant && target.hitCount<3){
		        		continue;
		        	}
		        	mScoreNum+=10*target.hitCount;
		            mScore.post(new Runnable() {
		    			
		    			@Override
		    			public void run() {
		    				mScore.setText("score: "+mScoreNum+"점");
		    				
		    			}
		    		});
		        	
		        	eType = EnemyType.None;
		        	Log.i("Test", "맞았습니다.");

//					            grid.removeObject(target);
		            targets.remove(target);
		            isUpdated = true;
		            isCorrectAnswer = false;
//								if (mCursor.moveToNext()){
//									mQuestion = mCursor.getString(1);
//									mMeaning = mCursor.getString(2);
//									mPictureFile = mCursor.getString(3);
//									Log.i("Test", "다시 읽은 question:"+mQuestion);
//								}	         
		        }
		    }
 
	    }

//	    touchPos.x = touchPos.y = 0;

	}
	
	
	
	private void drawVertex(Vertices ver, Texture tex){
		GL10 gl = glGraphics.getGL();
		gl.glEnable(GL10.GL_TEXTURE_2D);
		tex.bind();
		
		drawVertex(ver);		
		gl.glDisable(GL10.GL_TEXTURE_2D);
	}
    
	private void drawVertex(Vertices ver){
		ver.bind();
		ver.draw(GL10.GL_TRIANGLES, 0, 6);
		ver.unbind();		
	}
	
	public Bitmap makeBitmap(String str){
		Bitmap bitmap = Bitmap.createBitmap( 64, 64, Bitmap.Config.ARGB_4444 );
		Canvas canvas = new Canvas( bitmap );
		bitmap.eraseColor( 0 );
		Paint textPaint = new Paint();
		textPaint.setTextSize( 20 );
		textPaint.setAntiAlias( true );
		textPaint.setARGB( 0xff, 0x00, 0xff, 0xff );
		textPaint.setTextAlign( Paint.Align.LEFT );
		textPaint.setTextScaleX( 1.0f );
		canvas.drawText( str, 0.f, 15.f , textPaint);
		return bitmap;
	}
	
	@Override
	public void present(float deltaTime) {
	    GL10 gl = glGraphics.getGL();
	    gl.glViewport(0, 0, glGraphics.getWidth(), glGraphics.getHeight());
	    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	    gl.glMatrixMode(GL10.GL_PROJECTION);
	    gl.glLoadIdentity();
	    gl.glOrthof(0, WORLD_WIDTH, 0, WORLD_HEIGHT, 1, -1);
	    gl.glMatrixMode(GL10.GL_MODELVIEW);

	    
	    gl.glEnable(GL10.GL_BLEND);
        gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

//		batcher.beginBatch(items);
////		batcher.drawSprite(480 - 32, 320 - 32, 64, 64, Assets.pauseButtonRegion);
//		mFont.drawText(batcher, "Hello World", 1, 4);
//		batcher.endBatch();
		
		gl.glLoadIdentity();
		drawVertex(backVertices, background);

		gl.glEnable(GL10.GL_TEXTURE_2D);
		GameObject word = alphabets.get(0);
        gl.glLoadIdentity();
        batcher.beginBatch(wordTex);
        mFont.drawText(batcher, mOuputText, word.position.x, word.position.y);
        batcher.endBatch();
        gl.glDisable(GL10.GL_TEXTURE_2D);
        
        
        if (eType == EnemyType.Giant){
	        gl.glEnable(GL10.GL_TEXTURE_2D);
	        batcher.beginBatch(texture3);
	        int len = targets.size();
	        for(int i = 0; i < len; i++) {
	            Enemy giant = targets.get(i);
	            TextureRegion keyFrame = walkAnim.getKeyFrame(giant.walkingTime, Animation.ANIMATION_LOOPING);
	            batcher.drawSprite(giant.position.x, giant.position.y, giant.velocity.x < 0?1:-1, 3.0f, keyFrame);
	        }
	        batcher.endBatch();
	        gl.glDisable(GL10.GL_TEXTURE_2D);
        } else if (eType == EnemyType.Ship){
	        int len = targets.size();
	        for(int i = 0; i < len; i++) {               
	            GameObject target = targets.get(i);
	            gl.glLoadIdentity();
	            gl.glTranslatef(target.position.x, target.position.y, 0);
	            drawVertex(targetVertices, texture2);
	        }
        }

//        for(int i = 0; i < mQuestion.length(); i++) {       
//            wordTex = new Texture((GLGame)game, 
//            		makeBitmap(String.valueOf(mQuestion.toUpperCase().charAt(i))));
//            GameObject word = alphabets.get(i);
//            gl.glLoadIdentity();
//            gl.glTranslatef(word.position.x, word.position.y, 0);
//            drawVertex(wordVertices, wordTex);
//        }

        
        // 볼 그리는 루틴
	    if (isCorrectAnswer) { 
	    	if (eType == EnemyType.Giant){
	    		Enemy target = targets.get(0);
	    		for (int i = 0; i<3-target.hitCount; i++){
			    	gl.glLoadIdentity();
			    	gl.glTranslatef(0.2f+i*0.3f, WORLD_HEIGHT-1, 0);  
			    	drawVertex(ballVertices, texture);
	    		}
	    	} else {
		    	gl.glLoadIdentity();
		    	gl.glTranslatef(0.2f, WORLD_HEIGHT-1, 0);  
		    	drawVertex(ballVertices, texture);
	    	}
	    	if (isFired){
		        gl.glLoadIdentity();
		        gl.glTranslatef(ball.position.x, ball.position.y, 0);  
		        drawVertex(ballVertices, texture);
	    	}
	    }
	    
        gl.glLoadIdentity();
        gl.glTranslatef(cannon.position.x, cannon.position.y, 0);
        gl.glRotatef(cannon.angle, 0, 0, 1);          
        drawVertex(cannonVertices, texture);
        
//	    gl.glColor4f(1, 0, 0, 1);
	    for(int i = 0; i < castle.size(); i++) {               
	    	GameObject block = castle.get(i);
	    	gl.glLoadIdentity();
	    	gl.glTranslatef(block.position.x, block.position.y, 0);
	    	drawVertex(castleVertices);
	    }

	    
//	    gl.glColor4f(0, 0, 1, 1);
    	gl.glLoadIdentity();
    	gl.glTranslatef(sea.position.x, sea.position.y, 0);
    	drawVertex(oceanVertices);

	}

    @Override
    public void pause() {
        
    }

    @Override
    public void resume() {
    	isStart = true;
    	makeEnemy();
        texture = new Texture((GLGame)game, "atlas.png");      
        texture2 = new Texture((GLGame)game, "ship.gif");      
        texture3 = new Texture((GLGame)game, "walkanim.png");
//        bubbleTex = new Texture(((GLGame)game), "walkanim.png");
//        Bitmap bitmap = makeBitmap("Hello World");
        wordTex = new Texture((GLGame)game, "items.png");
        mFont = new Font(wordTex, 224, 0, 16, 16, 20);
        
        walkAnim = new Animation( 0.2f,
                                  new TextureRegion(texture3, 0, 0, 64, 64),
                                  new TextureRegion(texture3, 64, 0, 64, 64),
                                  new TextureRegion(texture3, 128, 0, 64, 64),
                                  new TextureRegion(texture3, 192, 0, 64, 64));

        explosionTexture = new Texture((GLGame)game, "explode.png", true);
		TextureRegion[] keyFrames = new TextureRegion[16];
		int frame = 0;
		for (int y = 0; y < 256; y += 64) {
			for (int x = 0; x < 256; x += 64) {
				keyFrames[frame++] = new TextureRegion(explosionTexture, x, y,
						64, 64);
			}
		}
		explosionAnim = new Animation(0.1f, keyFrames);
    }

	private void renderExplosion(GL10 gl, Vector2 position, float stateTime) {
//		TextureRegion frame = explosionAnim.getKeyFrame(stateTime,
//				Animation.ANIMATION_NONLOOPING);
//		
//		gl.glEnable(GL10.GL_BLEND);
//		gl.glPushMatrix();
//		gl.glTranslatef(position.x, position.y, 0);		
//		batcher2.beginBatch(explosionTexture);
//		batcher2.drawSprite(0, 0, 2, 2, frame);
//		batcher2.endBatch();
//		gl.glPopMatrix();
//		gl.glDisable(GL10.GL_BLEND);
	}
	
    @Override
    public void dispose() {
        
    }        
}
}
